/**
 * Created by humin on 2015/12/2.
 */
var DataUtils = {
    setData: function (newdata, nbs) {
        var l = 1;
        var data = newdata.data;
        for (var i = 0; i < data.length; i++) {
            if (data[i].title == 0) {
                continue;
            }
            data[i].title = nbs["number" + l];
            l++;
        }
        newdata.data = data;
        return newdata;
    },
    getData: function (newdata) {
        var datanumbers = {};
        var data = newdata.data;
        if (data != null && data.length > 0) {
            var l = 1;
            for (var i = 0; i < data.length; i++) {
                if (data[i].title == "0") {
                    continue;
                }
                datanumbers["number" + l] = parseInt(data[i].title);
                l++;
            }
        }
        return datanumbers;
    },
    getDataBase: function (id) {
        if (datas.length > 0) {
            for (var i = 0; i < datas.length; i++) {
                if (id == datas[i].id) {
                    return datas[i];
                    break;
                }
            }
        }
        return null;
    },
    getUrlParam: function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    },
    getSelectValue:function(value){
        var retData=[];
        for(var i=0;i<datas.length;i++){
            if(datas[i].value==value){
                retData.push(datas[i]);
            }
        }
        return retData;
    }
}
